package mammuthus.web; /**
* Created by fengbingjian on 15/4/30 17:29.
*/


import mammuthus.web.db.DB;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.webapp.WebAppContext;

/**
* 使用Jetty运行调试Web应用, 在Console输入回车快速重新加载应用.
*
* @author calvin
*/
public class Launcher {



    public static void main(String[] args) throws Exception {


        //需要事先加载数据库
        DB.init();

        String path = Thread.currentThread().getContextClassLoader().getResource("").getFile();

        path = path.replace("target/classes/", "");
        path = path.replace("classes/", "");

        //System.out.println(path);

        Server server = new Server(8089);

//        javax.servlet.http.HttpServletRequest

        String web = path + "src/main/webapp/";
        WebAppContext context = new WebAppContext();
        context.setDescriptor(web + "WEB-INF/web.xml");
        context.setResourceBase(web);
        context.setContextPath("/");
        context.setParentLoaderPriority(true);


        server.setHandler(context);

        server.start();
        server.join();
    }
}